//
//  ZLAlertConfig.swift
//  ZLAlert
//
//  Created by 赵振磊 on 2022/11/25.
//

import UIKit

/// 配置
public struct ZLAlertItemConfig {
    /// 文字font
    public var font: UIFont = UIFont.systemFont(ofSize: 16)
    /// 文字色
    public var color: UIColor = UIColor(red: 51/255.0, green: 51/255.0, blue: 51/255.0, alpha: 1.0)
    /// 背景色
    public var backgroundColor: UIColor = UIColor.clear
    /// 左中右
    public var alignment: NSTextAlignment = .center
    /// 边距
    public var insets: UIEdgeInsets = UIEdgeInsets.zero
    /// 对标题和内容设置无效
    public var height: CGFloat = 45
    /// 圆角
    public var cornerRadius: CGFloat = 0
    /// 边宽
    public var borderWidth: CGFloat = 0
    /// 边颜色
    public var borderColor: UIColor = .clear
    
    public init(){}
}

/// 配置
public class ZLAlertConfig: NSObject, NSCopying, NSMutableCopying {
    /// 单例
    public static let shared = ZLAlertConfig()
    /// 背景关闭
    public var tapBackgroundClose: Bool = true
    /// 标题默认配置
    public var titleConfig: ZLAlertItemConfig = {
        var config = ZLAlertItemConfig()
        config.font = UIFont.systemFont(ofSize: 16, weight: .bold)
        config.insets = UIEdgeInsets.init(top: 20, left: 0, bottom: 20, right: 0)
        return config
    }()
    /// 内容默认配置
    public var contentConfig: ZLAlertItemConfig = {
        var config = ZLAlertItemConfig()
        config.color = UIColor.init(red: 153/255.0, green: 153/255.0, blue: 153/255.0, alpha: 1.0)
        config.insets = UIEdgeInsets.init(top: 0, left: 23, bottom: 20, right: 23)
        return config
    }()
    /// 按钮默认配置
    public var buttonConfig: ZLAlertItemConfig = {
        var config = ZLAlertItemConfig()
        config.font = UIFont.boldSystemFont(ofSize: 16)
        return config
    }()
    /// 按钮默认配置
    public var cancelButtonConfig: ZLAlertItemConfig = {
        var config = ZLAlertItemConfig()
        config.font = UIFont.boldSystemFont(ofSize: 16)
        config.color = UIColor(red: 153/255.0, green: 153/255.0, blue: 153/255.0, alpha: 1.0)
        return config
    }()
    /// 线默认配置
    public var lineConfig: ZLAlertItemConfig = {
        var config = ZLAlertItemConfig()
        config.backgroundColor = UIColor.init(red: 153/255.0, green: 153/255.0, blue: 153/255.0, alpha: 0.1)
        config.height = 0.5
        return config
    }()
    /// 线输入框配置
    public var inputConfig: ZLAlertItemConfig = {
        var config = ZLAlertItemConfig()
        config.backgroundColor = UIColor.init(red: 249/255.0, green: 249/255.0, blue: 249/255.0, alpha: 1.0)
        config.insets = UIEdgeInsets.init(top: 0, left: 23, bottom: 0, right: 23)
        config.color = .black
        config.cornerRadius = 5
        config.height = 40
        return config
    }()
    /// 标题视图配置
    public var viewConfig: ZLAlertItemConfig = {
        var config = ZLAlertItemConfig()
        config.insets = UIEdgeInsets.init(top: 0, left: 0, bottom: 0, right: 0)
        return config
    }()
    private override init() {}
    public func copy(with zone: NSZone? = nil) -> Any {
        return self
    }
    public func mutableCopy(with zone: NSZone? = nil) -> Any {
        return self
    }
}
